package io.github.novaframe.web.vm;

import com.github.pagehelper.PageInfo;
import lombok.Data;

import java.util.List;

/**
 * @author Locki
 * @since 2017-10-19 10:48
 */
@Data
public class PageVM<T> {

    private PaginationVM pagination;
    private List<T> result;

    public PageVM<T> from(PageInfo<T> pageInfo) {
        this.pagination = PaginationVM.from(pageInfo);
        this.result = pageInfo.getList();
        return this;
    }

    public PageVM(PaginationVM paginationVM, List<T> result) {
        this.pagination = paginationVM;
        this.result = result;
    }

    public PageVM(){}

}
